﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using PPI.Entities;
using VMind.Global;

namespace PPI.Client.Logic
{
    public class LCentralOffice
    {
        public static List<ECentralOffice> GetAll()
        {
            List<ECentralOffice> listOffices = new List<ECentralOffice>();
            DataSet datasetOffice = WebConsumer.WCentralOffice.SelectAll();
            if(datasetOffice != null)
            {
                DataTable dtOffice = datasetOffice.Tables[0];

                foreach (DataRow dr in dtOffice.Rows)
                {
                    ECentralOffice office = new ECentralOffice();
                    office.Latitude = ConvertHelper.Todouble(dr["Latitude"]);
                    office.Longitude = ConvertHelper.Todouble(dr["Longitude"]);
                    office.Altitude = 0;
                    office.Address = ConvertHelper.Tostring(dr["Address"]);
                    office.Name = ConvertHelper.Tostring(dr["Name"]);
                    office.Id = ConvertHelper.ToInt32(dr["CentralOfficeId"]);
                    listOffices.Add(office);
                }

            }
            return listOffices;
        }

        
    }
}
